Repository navigation
Reduce WASI compiler memory growth and startup overhead - #170
Closed
vishvananda wants to merge 3 commits into
Closed
vishvananda wants to merge 3 commits into
vishvananda wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WebKit can copy the whole Wasm heap when memory grows without a fast-memory reservation. Many small WASI allocations become expensive. Creating a new compiler instance for every file also loses per-instance browser execution state.
Give the single-threaded WASI host a logical heap break and bounded spare capacity. Grow by 25%, with at most 16 MiB spare. Retry the exact amount needed if that reservation fails. Keep overflow, failure and alignment checks.
The WASI reference export also supplies two leaf assembly functions for reading and restoring the stack pointer, and a function for initializing and reading the logical heap break. The browser can save the initial process image, restore its data and stack between files, and clear only the heap range used by the preceding invocation. Reserved pages are then reused. The helper source is included in the frozen source profile and compiled during self-build. Native source sets stay unchanged apart from an empty translation unit; there is no new student requirement.
The browser reset implementation is in the incpption repository. Older compiler exports and the Emscripten Clang host keep their existing isolation behavior.
Validation:
The browser numbers above are local Linux WebKit measurements with phone emulation, not physical iPhone results. A calibrated comparison and full journey in real Mac Safari are running. Earlier heap-only Mac tests did not establish a speedup; the reusable process host is a separate improvement. The production site continues to use the published0.9.3 seed until a new release exports these helpers.